<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let s1 = 'http://127.0.0.1:5501/index.html',
      s2 = 'https://ma_zipeng.gitee.io/psewebsite/',
      s3 = 'http://159.75.3.121:8080/';
    let port = /html\/?$/g,
      judge = /\/$/g;
    if (s1.match(port)) {
      if (s1.match(judge)) {
        s1 = s1.substring(0, s1.length - 12);
      } else {
        s1 = s1.substring(0, s1.length - 11);
      }
    }
    console.log(s1);

  </script>
</body>

</html>